<%@ page contentType="text/html; charset=GBK"%>
<%@ page import="java.util.*" %>
<%@ page import="java.io.*" %>
<%@ page import="com.isomorphic.auth.*" %>
<%@ page import="com.isomorphic.rpc.*" %>
<%@ page import="com.isomorphic.datasource.*" %>
<%@ page import="com.isomorphic.sql.*" %>
<%@ page import="com.isomorphic.util.*" %>



<%
RPCManager rpc = new RPCManager(request, response, out);

Map credentials = (Map)rpc.getData();

//DataSource loginDS = DataSource.forName("syslogin");

ServletContext app=this.getServletContext(); 

System.out.println("application : " + app);

InputStream is = app.getResourceAsStream("/lc_shty/ds/syslogin.ds.xml");

System.out.println("xml : " + is);

StringBuffer xml = new StringBuffer();

byte[] b = new byte[4096];
for (int n; (n = is.read(b)) != -1;) {
	xml.append(new String(b, 0, n));
}

DataSource loginDS = DataSource.fromXML(xml.toString());

Map loginInfo = (Map)loginDS.fetchSingle(credentials);
	
//if(loginInfo != null) {	
	
	session.setAttribute( "userId", credentials.get("userName"));
	session.setAttribute( "userName", credentials.get("userName") );
	session.setAttribute( "password", credentials.get("password"));  

//}

System.out.println("session variables: " + session.getAttribute("userId"));

rpc.send(loginInfo);


%>